<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateStaffTable.
 */
class CreateStaffTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('staff', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('dorm_id')->nullable();
            $table->unsignedInteger('staff_position_id')->nullable();
            $table->unsignedInteger('department_id')->nullable();
            $table->unsignedInteger('couple_id')->nullable();
            $table->boolean('is_fee_bearer')->default(true);
            $table->string('name',10);
            $table->string('card_num',20)->nullable();
            $table->string('id_card',20);
            $table->tinyInteger('sex')->default(2);//0:female,1:male,2:unknow
            $table->string('phone',50)->nullable();
            $table->tinyInteger('status')->default(1);
            $table->string('remark')->nullable();
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrent();
            $table->foreign('dorm_id')->references('id')->on('dorms')
                ->onDelete('set null');
            $table->foreign('staff_position_id')->references('id')->on('staff_positions')
                ->onDelete('set null');
            $table->foreign('department_id')->references('id')->on('departments')
                ->onDelete('set null');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('staff');
	}
}
